package cn.wcy.design_patterns.creationtype01.abstractfactory02;

import cn.hutool.core.text.CharSequenceUtil;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class Factory {

    private static final Map<String, CacheService> strategyMap = new ConcurrentHashMap<>(3);

    public static CacheService getInvokeStrategy(String serviceSimpleName) {
        return strategyMap.get(serviceSimpleName);
    }

    //表驱动
    public static void register(String serviceSimpleName, CacheService cacheService) {
        if (CharSequenceUtil.isBlank(serviceSimpleName) || null == cacheService) {
            return;
        }
        strategyMap.put(serviceSimpleName, cacheService);
    }
}
